package v1

import (
	"gin-vue-admin/global"
    "gin-vue-admin/model"
    "gin-vue-admin/model/request"
    "gin-vue-admin/model/response"
    "gin-vue-admin/service"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

// @Tags BillList
// @Summary 创建BillList
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.BillList true "创建BillList"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /billList/createBillList [post]
func CreateCalendarPoint(c *gin.Context) {
	var cpoint model.CalendarPoint
	_ = c.ShouldBindJSON(&cpoint)
	if err := service.CreateCalendarPoint(cpoint); err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
		response.FailWithMessage("创建失败", c)
	} else {
		response.OkWithMessage("创建成功", c)
	}
}

// @Tags BillList
// @Summary 批量删除BillList
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除BillList"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /billList/deleteBillListByIds [delete]
func DeleteCalendarPointByIds(c *gin.Context) {
	var IDS request.IdsReq
    _ = c.ShouldBindJSON(&IDS)
	if err := service.DeleteCalendarPointByIds(IDS); err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
		response.FailWithMessage("批量删除失败", c)
	} else {
		response.OkWithMessage("批量删除成功", c)
	}
}

func GetCalendarPoint(c *gin.Context) {
	var pageInfo request.CalendarPointSearch
	_ = c.ShouldBindQuery(&pageInfo)
	if err, list, total := service.GetCalendarPointInfoList(pageInfo); err != nil {
		global.GVA_LOG.Error("获取失败", zap.Any("err", err))
		response.FailWithMessage("获取失败", c)
	} else {
		response.OkWithDetailed(response.PageResult{
			List:     list,
			Total:    total,
			Page:     pageInfo.Page,
			PageSize: pageInfo.PageSize,
		}, "获取成功", c)
	}
}
